package com.smarttiger.zero.admin.dao;

import com.smarttiger.zero.admin.entity.RoleMenuModel;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Component
public interface RoleMenuDao extends BaseDao<RoleMenuModel> {
    public List<RoleMenuModel> findAllByGroupIdAndParentMenuId(String groupId,String parentId);
    public List<RoleMenuModel> findAllByGroupIdAndParentMenuIdIsNull(String groupId);

    public RoleMenuModel findByGroupIdAndMenuId(String group,String menuId);
    @Modifying
    @Query("delete from RoleMenuModel m where m.groupId = ?1")
    public void deleteByGroupId(String groupId);

    @Query("select rm.menuId from RoleMenuModel rm " +
            "where rm.groupId in ?1 ")
    public Set<String> getAllByMutiGroup(List<String> groups);
}
